-- stack: in.01 -- format: 8 (HyperCard 1) -- flags: 0x1000 (none) -- protect password hash: 0 -- maximum user level: 5 (scripting) -- window: Rect(x1=0, y1=0, x2=0, y2=0) -- screen: Rect(x1=0, y1=0, x2=0, y2=0) -- card dimensions: w=0 h=0 -- scroll: x=0 y=0 -- background count: 3 -- first background id: 2734 -- card count: 4 -- first card id: 2966 -- list block id: 4588 -- print block id: 2124 -- font table block id: 0 -- style table block id: 0 -- free block count: 0 -- free size: 0 bytes -- total size: 50080 bytes -- stack block size: 10240 bytes -- created by hypercard version: 0x01208000 -- compacted by hypercard version: 0x01228000 -- modified by hypercard version: 0x01228000 -- opened by hypercard version: 0x01228000 -- patterns[0]: 0x0000000000000000 -- patterns[1]: 0x8000000008000000 -- patterns[2]: 0x8800220088002200 -- patterns[3]: 0x8888222288882222 -- patterns[4]: 0x88AA22AA88AA22AA -- patterns[5]: 0xCCAA33AACCAA33AA -- patterns[6]: 0xEEAABBAAEEAABBAA -- patterns[7]: 0xEEBBBBEEEEBBBBEE -- patterns[8]: 0xFFBBFFEEFFBBFFEE -- patterns[9]: 0xFFBBFFFFFFBBFFFF -- patterns[10]: 0x8010022001084004 -- patterns[11]: 0xFFFFFFFFFFFFFFFF -- patterns[12]: 0x8822882288228822 -- patterns[13]: 0x1122448811224488 -- patterns[14]: 0xC4800C6843023026 -- patterns[15]: 0xB130031BD8C00C8D -- patterns[16]: 0xAA00AA00AA00AA00 -- patterns[17]: 0x8822552288225522 -- patterns[18]: 0x8855225588552255 -- patterns[19]: 0x77DD77DD77DD77DD -- patterns[20]: 0x8000000000000000 -- patterns[21]: 0xAA55AA55AA55AA55 -- patterns[22]: 0x038448300C020101 -- patterns[23]: 0x8244394482010101 -- patterns[24]: 0x8814224188412214 -- patterns[25]: 0x8080413E080814E3 -- patterns[26]: 0x22048C7422179810 -- patterns[27]: 0xBE808808EB088880 -- patterns[28]: 0x25C8328964244C92 -- patterns[29]: 0xA29C41BE2AC914EB -- patterns[30]: 0x40A00000040A0000 -- patterns[31]: 0x8040200002040800 -- patterns[32]: 0xAA00800088008000 -- patterns[33]: 0xFF80808080808080 -- patterns[34]: 0x081C22C180010204 -- patterns[35]: 0xFF808080FF080808 -- patterns[36]: 0xF87422478F172271 -- patterns[37]: 0xBF00BFBFB0B0B0B0 -- patterns[38]: 0xFF7FBE5DA2418000 -- patterns[39]: 0xFAF5FAF5A050A050 -- checksum: 0x0 ----- HyperTalk script ----- on openStack -- do some checking to be sure all is well... if the version < 1.2 then beep answer "Sorry, need newer version of HyperCard!" end if if the number of this card is 1 then if field "Text" is empty then put "Free Text Browser - Copyright © 1990 - Mark Zimmermann" & return & "Click on the '?' for help." & return & "This program is free and comes with NO WARRANTY whatsoever!" into field "Text" end if end if initGlobals -- set up many things for this stack if item 4 of the screenrect <= 342 then hide menuBar pass openStack end openStack on closeStack -- close out files, vars, empty fields nicely set cursor to watch lock screen repeat for the number of cards -- close all database files if the short name of this bkgnd is "BrowserBg" then closeDatabase go to next card end repeat show menuBar pass closeStack end closeStack on closeDatabase -- called before opening a file as well as when leaving the stack get openCloseFiles (getTextFileRefNum(), getKeyFileRefNum(), getPtrFileRefNum()) if not (getSubsetHandle(1) = 0 or getSubsetHandle(1) = empty) then get zbrowser ("RELEASESUBSET", getSubsetHandle(1)) setSubsetHandle 1,0 end if if not (getSubsetHandle(2) = 0 or getSubsetHandle(2) = empty) then get zbrowser ("RELEASESUBSET", getSubsetHandle(2)) setSubsetHandle 2,0 end if put empty into field "FTVars" put empty into field "Index1" put empty into field "Index2" put empty into field "Context" put empty into field "Text" put empty into field "Database Name" if the height of field "Text" > 169 then send mouseUp to bg button id 44 end if hide field "searchPattern1" hide field "searchPattern2" hide bg button "and subsets" hide bg button "or subsets" hide bg button "not subset 1" hide bg button "not subset 2" hide bg button "fill subset 1" hide bg button "fill subset 2" end closeDatabase on initGlobals -- initialize many things here for the stack to use globally global indexLines, contextLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth, contextLineLength, contextWordOffset, maxContextLinesSkipped, textChunkSize, textOffset, errorCount, contextGutterWidth, whichSubset put 7 into indexLines -- hold this many lines in Index fields put 7 into contextLines -- hold this many lines in Context field put 100 into maxIndexSampleCount -- sample size during subset counts put 5 into indexCountWidth -- this many digits of count info for Index put 28 into indexKeyWidth -- this many letters of Index words put 80 into contextLineLength -- this many letters of Context put 35 into contextWordOffset -- key word starts in this column put 100 into maxContextLinesSkipped -- make a line of dots after this many lines in subset are skipped put 8192 into textChunkSize -- grab this much for text field put 4096 into textOffset -- put key word this far into text chunk put 0 into errorCount -- initialize counter to control error display put 0 into contextGutterWidth -- spaces before key word put 1 into whichSubset -- identify which subset, 1 or 2, is being used end initGlobals on checkOpenDatabase -- test to catch attempt to operate without an open indexed file; -- try turning it into an "Open Database" request if so! if (getTextFileRefNum() = 0 or getTextFileRefNum() = empty) then beep answer "No database open!" exit to HyperCard end if end checkOpenDatabase function clickedLineNum -- compute which line number of the field got the click return 1 + trunc((item 2 of the clickLoc - (item 2 of (the rectangle of the target))) / (the textheight of the target)) end clickedLineNum function clickedOnLeftHalf -- see if click was on left half of the button, for AND and OR subsets put item 1 of the clickLoc into clickX put ((item 1 of the rect of the target) + (item 3 of the rect of the target)) / 2 into midPointX return (clickX < midPointX) end clickedOnLeftHalf on browseIndex1 -- fill Index field #1 global indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth get zbrowser ("INDEX", getwordnum1(), indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth, getKeyFileRefNum(), getPtrFileRefNum(), getSubsetHandle(1)) put line 1 to indexLines of It into field "Index1" setInstanceList1 (line (indexLines+1) to (2*indexLines) of It) end browseIndex1 on browseIndex2 -- fill Index field #2 global indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth get zbrowser ("INDEX", getwordnum2(), indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth, getKeyFileRefNum(), getPtrFileRefNum(), getSubsetHandle(2)) put line 1 to indexLines of It into field "Index2" setInstanceList2 (line (indexLines+1) to (2*indexLines) of It) end browseIndex2 on browseContext lineOffset -- fill the Context field global contextLines, contextLineLength, contextWordOffset, maxContextLinesSkipped, contextGutterWidth, whichSubset get zbrowser ("CONTEXT", getInstanceNum(), contextLines, lineOffset, contextLineLength, contextWordOffset, maxContextLinesSkipped, contextGutterWidth, getPtrFileRefNum(), getTextFileRefNum(), getSubsetHandle(whichSubset)) put line 1 to contextLines of It into field Context setTextPtrList (line (contextLines+1) to (2*contextLines) of It) end browseContext -- -- the remaining functions set and fetch values of various useful -- quantities; do it this way to hide the details of how things are -- stored.... -- function getTextFileRefNum return line 1 of field FTVars end getTextFileRefNum on setTextFileRefNum refNum put refNum into line 1 of field FTVars end setTextFileRefNum function getKeyFileRefNum return line 2 of field FTVars end getKeyFileRefNum on setKeyFileRefNum refNum put refNum into line 2 of field FTVars end setKeyFileRefNum function getPtrFileRefNum return line 3 of field FTVars end getPtrFileRefNum on setPtrFileRefNum refNum put refNum into line 3 of field FTVars end setPtrFileRefNum function getWordNum1 return line 4 of field FTVars end getWordNum1 on setWordNum1 wordNum put wordNum into line 4 of field FTVars end setWordNum1 function getWordNum2 return line 5 of field FTVars end getWordNum2 on setWordNum2 wordNum put wordNum into line 5 of field FTVars end setWordNum2 function getInstanceNum return line 6 of field FTVars end getInstanceNum on setInstanceNum instanceNum put instanceNum into line 6 of field FTVars end setInstanceNum function getTextStart return line 7 of field FTVars end getTextStart on setTextStart textStart put textStart into line 7 of field FTVars end setTextStart function getTextTarget return line 8 of field FTVars end getTextTarget on setTextTarget textTarget put textTarget into line 8 of field FTVars end setTextTarget function getTextEnd return line 9 of field FTVars end getTextEnd on setTextEnd textEnd put textEnd into line 9 of field FTVars end setTextEnd function getSubsetHandle subsetNumber return line 9+subsetNumber of field FTVars end getSubsetHandle on setSubsetHandle subsetNumber, handle put handle into line 9+subsetNumber of field FTVars end setSubsetHandle function getNeighborhoodSize return line 12 of field FTVars end getNeighborhoodSize on setNeighborhoodSize size put size into line 12 of field FTVars end setNeighborhoodSize -- lines 13 through 19 of field FTVars are currently unused function getInstanceList1item instanceNum return line 19+instanceNum of field FTVars end getInstanceList1item on setInstanceList1 instanceList global indexLines put instanceList into line 20 to 19+indexLines of field FTVars end setInstanceList1 function getInstanceList2item instanceNum global indexLines return line 19+indexLines+instanceNum of field FTVars end getInstanceList2item on setInstanceList2 instanceList global indexLines put instanceList into line 20+indexLInes to 19+2*indexLines of field FTVars end setInstanceList2 function getTextPtrListInstanceItem itemNum global indexLines, contextLines return word 1 of line 19+2*indexLines+itemNum of field FTVars end getTextPtrListInstanceItem function getTextPtrListPtrItem itemNum global indexLines, contextLines return word 2 of line 19+2*indexLines+itemNum of field FTVars end getTextPtrListPtrItem on setTextPtrList textPtrList global indexLines, contextLines put textPtrList into line 20+2*indexLInes to 19+2*indexLines +contextLines of field FTVars end setTextPtrList